import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        //索引
        Scanner sc = new Scanner(System.in);
        System.out.print("请输入要访问的网页：" + "(输入end结束访问)"+"(输入add添加新的网页)");

        //创建集合
        ArrayList<wb> list = new ArrayList<>();
        //创建网页
        int n1 = 0, n2 = 0, n3 = 0;
        while (true) {
            String input = sc.nextLine();

            if ("wb1".equals(input)) {
                n1 += 1;
            } else if ("wb2".equals(input)) {
                n2 += 1;
            } else if ("wb3".equals(input)) {
                n3 += 1;
            } else if ("end".equals(input)) {
                break;
            } else if (!("wb1".equals(input) || "wb2".equals(input) || "wb3".equals(input))) {
                System.out.print("当前网页不存在，请添加后再查询。");
                System.out.print("请在此处输入要添加的网页名称：");
                wb wb4 = new wb();
                String id = sc.next();
                wb4.setId(id);

                System.out.print("请输入访问次数");
                String number = sc.next();
                wb4.setNumber(number);

                System.out.print("正在生成访问时间");
                String date = sc.next();
                wb4.setDate(date);
                list.add(wb4);
                break;
            }
        }
            DATE d1 = new DATE();
            DATE d2 = new DATE();
            DATE d3 = new DATE();
            DATE d4 = new DATE();

            wb w1 = new wb("网页名称：wb1", "wb1的访问次数为："+ n1,  "上一次访问时间为：" + d2);
            wb w2 = new wb("网页名称：wb2", "wb2的访问次数为：" + n2, "上一次访问时间为：" + d2);
            wb w3 = new wb("网页名称：wb3", "wb3的访问次数为：" + n3, "上一次访问时间为：" + d3);

            //添加元素
            list.add(w1);
            list.add(w2);
            list.add(w3);

        for (int i = 0; i < list.size(); i++) {
            wb w = list.get(i);
            System.out.println(w.getId()+","+w.getNumber()+","+w.getDate());
        }

        System.out.print("访问次数排行榜：");
        if (n1>n2&&n1>n3&&n2>n3) {
            System.out.print("N1"+"wb1"+";"+"N2"+"wb2"+";"+"N3"+"wb3");
        }
        if (n1>n2&&n1>n3&&n3>n2) {
            System.out.print("N1"+"wb1"+";"+"N2"+"wb3"+";"+"N3"+"wb2");
        }
        if (n2>n1&&n2>n3&&n3>n1) {
            System.out.print("N1"+"wb2"+";"+"N2"+"wb3"+";"+"N3"+"wb1");
        }
        if (n2>n1&&n2>n3&&n1>n3) {
            System.out.print("N1"+"wb2"+";"+"N2"+"wb1"+";"+"N3"+"wb3");
        }
        if (n3>n1&&n3>n2&&n2>n1) {
            System.out.print("N1"+"wb3"+";"+"N2"+"wb2"+";"+"N3"+"wb1");
        }
        if (n3>n1&&n3>n2&&n1>n2) {
            System.out.print("N1"+"wb3"+";"+"N2"+"wb1"+";"+"N3"+"wb2");
        }
        }
}
